﻿using System;
using System.Data;
using System.Collections.Generic;
using eTMS.Controllers.GiangVienLopTinChiService;
namespace eTMS.Controllers
{
    public class GiangVienLopTinChiController : GiangVienLopTinChiControllerBase
    {
        public GiangVienLopTinChiController()
            : base()
        {
        }
        public void LoadAllDSWithGiangVienLopByHocKyNamHoc(int NamHoc_ID, int HocKy_ID)
        {
            _Table = dao.SelectAllDSWithLopTinChiGiaoVienFilter("LopTinChi.NamHoc_ID=" + NamHoc_ID.ToString() + " AND LopTinChi.HocKy_ID=" + HocKy_ID.ToString()).Tables[0];
        }
        private DataTable _Table;
        private GiangVienLopTinChiEntity oGiangVienLopTinChi;
        public GiangVienLopTinChiEntity GiangVienLopTinChiObject
        {
            get
            {
                return oGiangVienLopTinChi;
            }
            set
            {
                oGiangVienLopTinChi = value;
            }
        }
        public DataTable Table
        {
            get
            {
                return _Table;
            }
            set
            {
                _Table = value;
            }
        }

        public void LoadObject(Int32 GiangVienLopTinChi_ID)
        {
            oGiangVienLopTinChi = dao.SelectOne(GiangVienLopTinChi_ID);

        }
        public bool AddNew()
        {
            if (oGiangVienLopTinChi == null) return false;
            bool result = true;
            try
            {
                oGiangVienLopTinChi = dao.SaveRet(oGiangVienLopTinChi);
                result &= !oGiangVienLopTinChi.IsNullGiangVienLopTinChi_ID;
            }
            catch
            {
                result = false;
            }

            return result;
        }
        public bool Update()
        {
            if (oGiangVienLopTinChi == null) return false;
            return dao.Update(oGiangVienLopTinChi);
        }
        public bool Delete()
        {
            if (oGiangVienLopTinChi == null) return false;
            bool retvalue = dao.Delete(oGiangVienLopTinChi);

            return retvalue;
        }
        public bool DeleteByID(Int32 GiangVienLopTinChi_ID)
        {
            bool retvalue = dao.DeleteByID(GiangVienLopTinChi_ID);

            return retvalue;
        }
        public void ResetObject()
        {
            this.oGiangVienLopTinChi = new GiangVienLopTinChiEntity();
        }
        public void MapObjectToDataRow(DataRow row)
        {
            this.MapObjectToDataRow(this.GiangVienLopTinChiObject, row);
        }
        public GiangVienLopTinChiEntity LoadGiangVienLopTinChi(Int32 GiangVienLopTinChi_ID)
        {
            GiangVienLopTinChiEntity o = dao.SelectOne(GiangVienLopTinChi_ID);
            return o;
        }
    }
}
